import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "../views/Login/Login"
import Manger from "../views/Manger/Manger"
import Goods from "../views/Goods/Goods"
import Store from '../store/index'
import Order from '../views/Order/Order'
import User from '../views/User/User'
import Home from '../views/Home/index'
import Role from '../views/Role/Role'
import Notice from '../views/Notice/Notice'


Vue.use(VueRouter)

const routes = [{
    path: "/",
    name: "Login",
    component: Login
}, {
    path: "/manger",
    component: Manger,
    redirect: "/home",
    beforeEnter: (to, from, next) => {
        if (Store.state.islogin) {
            next()
        } else {
            next({ name: "Login" })
        }
    },
    children: [{
        path: "/goods",
        component: Goods
    }, {
        path: '/order',
        component: Order
    },
    {
        path: '/user',
        component: User
    },
    {
        path: '/home',
        component: Home
    },
    {
        path: '/role',
        component: Role
    },
    {
        path: "/goods",
        component: Goods
    }, {
        path: '/order',
        component: Order
    },
    {
        path: '/user',
        component: User
    },
    {
        path: '/notice',
        component: Notice
    },
    {
        path: '/home',
        component: Home
    }
    ]
}]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router